package com.ybc.创建和销毁对象;


//元素多 + 规范化 --> 构建器模式
public class UseBuilder {

    private String name;
    private int age;


    private UseBuilder(MyBuilder builder ) {
        this.name = builder.name;
        this.age = builder.age;
    }


    public static class MyBuilder {
        private String name;
        private int age;

        public MyBuilder name(String name) {
            this.name = name;
            return this;
        }

        public MyBuilder age(int age) {
            this.age = age;
            return this;
        }

        public UseBuilder build() {
            return new UseBuilder(this);
        }
    }

    @Override
    public String toString() {
        return "UseBuilder{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
